package Aggregation;

public class Module{
	// Holds the name of the Module.
	String name;
	// Holds the Modules Lectures.
	Lecture[] lectures = new Lecture[8];
	// Holds the number of lectures currently in the Module.
	int numLectures;
	
	// Empty constructor allows module to be created before Lectures are added.
	Module() {
		numLectures = 0;
	}
	
	// Single constructor allows module to be initialized with one Lecture.
	Module(String aName, Lecture aLecture) {
		// Set the Module name.
		name = aName;
		numLectures = 0;
		// Test there are less than 8 Lectures.
		lectures[numLectures] = aLecture;
		++numLectures;
	}
	
	// Constructor takes an array of 8 Lectures to initialize the Module.
	Module(String aName, Lecture[] lectureSet) {
		// Set the Module name.
		name = aName;
		// Test the array has the correct amount of Lectures within.
		if (lectureSet.length <= 8) {
			lectures = lectureSet;
			numLectures = lectureSet.length;
		}
		else { // Otherwise tell the user there were too many lectures to fit into the Module.
			System.out.println("Lectures not set, array did not contain 8 Lectures!");
			numLectures = 0;
		}
	}
	
	// Adds a Lecture to the Module.
	public void addLecture(Lecture aLecture) {
		// Check there is space for the lecture.
		if (numLectures < 8) {
			lectures[numLectures] = aLecture;
			++numLectures;
		}
		else {
			System.out.println("There are already the maximum 8 lectures in this module!");
		}
	}
	
	// Prints the details of the Module.
	public void printDetails() {
		System.out.println(name);
		// Print all the lecture names.
		for (int i=0; i < numLectures; ++i) {
			lectures[i].printDetails();
		}
	}
}
